<?php


namespace gizwits\src\Request;


use gizwits\src\Config;
use gizwits\src\Exception\GizwitsException;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;

class Request
{

    public function request($type, $url, array $data = [])
    {
        try {
            $client = new Client();
            dump($data);
//            $client->post()
            $res = $client->request($type, $url, [
                'headers'   => [
                    'X-Gizwits-Application-Id'  => Config::APP_ID,
//                    'X-Gizwits-User-token'      => '032123132',
//                    'X-Gizwits-Application-Auth'=> '',
//                    'X-Gizwits-Timestamp'       => time(),
//                    'X-Gizwits-Signature'       => ''
                ],
                'body'   => json_encode($data),
                'verify'        => false,
//                'debug' => true
            ]);
            dump($res);
            if (!$res->getStatusCode() !== 200)
            {
                return false;
            }
            return $res->getBody()->getContents();
        }  catch (GuzzleException $e) {
            throw new GizwitsException($e->getMessage());
        }
    }
}